import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'
import { getResumeContent } from '../../services/modules/resume'
export const fetchResumeInfoAction = createAsyncThunk(
  'fetchResumeInfo',
  async (_, { dispatch }) => {
    const res = await getResumeContent()
    console.log(res, '简历信息数据')
    dispatch(setResumeContent(res.data.records[0]))
  }
)
const resumeInfoSlice = createSlice({
  name: 'resumeInfoSlice',
  initialState: {
    resumeData: {
      baseInfo: {
        birthday: '22岁',
        email: '871602699@qq.com',
        ethnic: '汉族',
        height: '175',
        imgUrl: '',
        name: '赵世伟',
        origin: '河南平顶山',
        politicalLandscape: '河南永城',
        sex: '男',
        telephone: '19838558988',
        wight: '60kg',
        workYear: '1'
      },
      campusExperience: {
        content:
          '学习前端基础知识，与导师和后端同学交流项目方案，共同开发真实项目例如《咖喱鱼APi接口开发平台》《简历魔法屋》等，负责整个双创空间的前端项目开发',
        endTime: '2022-9-2',
        experienceName: '睿翼工坊',
        role: '讲师',
        startTime: '2021-11-2'
      },
      certificateHonor:
        '<p><b>语言能力：</b>大学英语6级证书，荣获全国大学生英语竞赛一等奖，能够熟练的进行交流、读写。</p><p><b>计算机：</b>计算机二级证书，熟练操作windows平台上的各类应用软件，如Word、Excel。</p><p><b>团队能力：</b>具有丰富的团队组建与扩充经验和项目管理与协调经验。</p>',
      createId: 0,
      createTime: '2023-9-19',
      hobbies: '听音乐',
      id: 0,
      jobIntent: {
        city: '杭州',
        expectSalary: '12k',
        intent: '前端工程师',
        onboardTime: '一周内'
      },
      projectExperience: {
        content:
          '<ul><li>项目介绍：一款在线简历服务平台，可挑选简历模板、实时编辑简历、购买简历服务、在线聊天指导优化简历、后台管理等。</li><li>技术栈 ：React18+Axios+Mui+Reduxjs/toolkit+Websocket+styled-components</li><li>项目亮难点：</li></ul><p>　　　1. 二次封装UI库和自定义组件，透传style、className、props等实现组件多处复用</p><p>　　　2. 支持双token身份验证实现无感刷新；简历编辑实时预览、自定义模板样式、支持PDF，JSON格式导出</p><p>　　　3. 支持下单各种简历优化指导服务，对订单进行存疑、评价、退款、删除等操作　　</p><p>　　　4. 支持在线与简历服务师交流、AI优化简历；简历模块支持自定义调整、拖拽等操作</p><ul><li>性能优化	</li></ul><p>　　　1. 使用CSS in JS实现CSS模块化；Websocket使用心跳机制，实现断线重连</p><p>　　　2. 组件通过memo包裹并使用useCallback，useMemo等hooks使组件实现最小原子渲染　　</p><p>　　　3. 简历模板使用虚拟列表渲染；首页通过图片、路由懒加载使首屏渲染时间缩短约60%</p>',
        endTime: '2023-6-1',
        projectName: '简历魔法屋（校科技创新基金会项目）',
        role: '前端工程师',
        startTime: '2023-1-1'
      },
      selfEvaluation:
        '<p>热衷于前端技术，积极进取，擅长与同事沟通交流，善于总结经验并撰写高质量博客，同时善于运用AI提升开发效率。</p>',
      skillSpecialties:
        '<ol><li>熟练掌握HTML5、CSS3、JavaScript、ES6+，能够使用TypeScript进行开发</li><li>熟悉Sass / Less预编译器，熟悉TailWindCSS、UnoCSS语法，熟练使用CSS in JS技术</li><li>熟悉React生态及其部分原理，熟练封装公共组件和自定义hooks</li><li>熟悉各种React Hooks、React ToolKit、ahooks、Zustand、React&nbsp;Spring等</li><li>熟悉Git、Webpack等前端自动化工具；了解前端性能优化的实现、能使运用Prettier / Eslint等规范项目编码</li><li>熟悉常见的数据结构及算法；了解HTTP、TCP/IP等主流协议，对浏览器原理有一定的了解</li><li>了解Vue2.x、Vue3.x、VueX、Pinia等，熟悉Ant Design、Material UI、Element Plus等组件库</li><li>了解Node、Express、Linux、MySQL等</li></ol>',
      templateId: 0,
      updateTime: '',
      workExperience: {
        companyName: '即时设计',
        content:
          '<ul><li>负责即时AI1.3版本UI重构、部分功能实现、BUG修复等</li><li>封装公共组件和自定义hooks，如响应式模型卡片/轮播图、图像控制、新手引导等 </li><li>负责AI生图生成队列（滚动懒加载、实时拖动排序、伪置顶等）的开发</li><li>负责灵感画布侧边栏（可吸附、拖动、边缘检测、自定义配置）的开发</li><li>负责在线UI编辑器设置样式、自动布局等功能</li><li>优化后台管理、新增字段；增加搜索、排序、筛选等功能</li></ul>',
        endTime: '2023-9-1',
        posts: '前端实习生',
        startTime: '2023-6-1'
      }
    },
    templateId: 2
  },
  reducers: {
    setTemplateId(state, { payload }) {
      state.templateId = payload
    },
    setBaseInfo(state, { payload }) {
      state.resumeData.baseInfo = payload
    },
    setJobIntent(state, { payload }) {
      state.resumeData.jobIntent = payload
    },
    setWorkExpeInfo(state, { payload }) {
      state.resumeData.workExperience.content = payload
    },
    setSchoolExpeInfo(state, { payload }) {
      state.resumeData.schoolExpeInfo = payload
    },
    // dispatch项目经验内容
    setProjectExperienceName(state, { payload }) {
      state.resumeData.projectExperience.projectName = payload
    },
    setProjectExperienceRole(state, { payload }) {
      state.resumeData.projectExperience.role = payload
    },
    setProjectExperienceStartTime(state, { payload }) {
      state.resumeData.projectExperience.startTime = payload
    },
    setProjectExperienceEndTime(state, { payload }) {
      state.resumeData.projectExperience.endTime = payload
    },
    setProjectExperienceContent(state, { payload }) {
      state.resumeData.projectExperience.content = payload
    },
    // dispatch工作经验内容
    setWorkExperienceName(state, { payload }) {
      state.resumeData.workExperience.companyName = payload
    },
    setWorkExperienceRole(state, { payload }) {
      state.resumeData.workExperience.posts = payload
    },
    setWorkExperienceStartTime(state, { payload }) {
      state.resumeData.workExperience.startTime = payload
    },
    setWorkExperienceEndTime(state, { payload }) {
      state.resumeData.workExperience.endTime = payload
    },
    setWorkExperienceContent(state, { payload }) {
      state.resumeData.workExperience.content = payload
    },
    //dispatch校园经历内容
    setCampusExperienceName(state, { payload }) {
      state.resumeData.campusExperience.experienceName = payload
    },
    setCampusExperienceRole(state, { payload }) {
      state.resumeData.campusExperience.role = payload
    },
    setCampusExperienceStartTime(state, { payload }) {
      state.resumeData.campusExperience.startTime = payload
    },
    setCampusExperienceEndTime(state, { payload }) {
      state.resumeData.campusExperience.endTime = payload
    },
    setCampusExperienceContent(state, { payload }) {
      state.resumeData.campusExperience.content = payload
    },
    //
    setSelfEvaluation(state, { payload }) {
      state.resumeData.selfEvaluation = payload
    },
    setSkillSpecialties(state, { payload }) {
      state.resumeData.skillSpecialties = payload
    },
    setCertificateHonor(state, { payload }) {
      state.resumeData.certificateHonor = payload
    },
    setResumeContent(state, { payload }) {
      state.resumeData = payload
    }
  }
})
export const {
  setTemplateId,
  setBaseInfo,
  setJobIntent,
  setWorkExpeInfo,
  setSchoolExpeInfo,
  setProjectExperienceName,
  setProjectExperienceRole,
  setProjectExperienceStartTime,
  setProjectExperienceEndTime,
  setProjectExperienceContent,
  setWorkExperienceName,
  setWorkExperienceRole,
  setWorkExperienceStartTime,
  setWorkExperienceEndTime,
  setWorkExperienceContent,
  setCampusExperienceName,
  setCampusExperienceRole,
  setCampusExperienceStartTime,
  setCampusExperienceEndTime,
  setCampusExperienceContent,
  setSelfEvaluation,
  setSkillSpecialties,
  setCertificateHonor,
  setResumeContent
} = resumeInfoSlice.actions
export default resumeInfoSlice.reducer
